<?php
/**
 * 分销
 */
namespace app\cps\controller;

use think\facade\Request;
use app\common\Error;
use app\common\Common;
use app\cps\service\DistributionService;

class Distribution extends Base
{
    private $service;

    public function __construct(DistributionService $service)
    {
        parent::__construct();
        $this->service = $service;
    }

    // 渲染分销商分成统计列表页
    public function dividedStatisticsIndex()
    {
        return view();
    }

    // 分销商分成统计列表
    public function dividedStatisticsList()
    {
        $params = Request::param();
        $data = $this->service->getDividedStatisticsList($params, $this->getUserInfo());

        return Common::success($data);
    }

    // 分成合计
    public function divideIntoTotal()
    {
        $params = Request::param();
        $data = $this->service->getDivideIntoTotal($params, $this->getUserInfo());

        return Common::success($data);
    }

    // 渲染分销结算列表页
    public function distributionSettlementIndex()
    {
        return view();
    }

    // 分销结算列表
    public function distributionSettlementList()
    {
        $params = Request::param();
        $data = $this->service->getDistributionSettlementList($params, $this->getUserInfo());

        return Common::success($data);
    }

    // 提交结算申请
    public function submitSettlementApply()
    {
        $params = Request::param();
        $data = $this->service->submitSettlementApply($params);
        if (!empty($data['message'])) {
            return Common::fail($data['message']);
        }

        return Common::success();
    }

    // 分销商详情
    public function detail()
    {
        $data = $this->service->getDistributionDetail($this->getUserInfo());

        return Common::success($data);
    }

    // 渲染分销商H5短信分成列表
    public function smsSharingIndex()
    {
        return view();
    }

    // 分销商H5短信分成列表
    public function smsSharingList()
    {
        $params = Request::param();

        $data = $this->service->getSmsSharingList($params, $this->getUserInfo());

        return Common::success($data);
    }
}